
function nextStep(actor){
var nodeId=$("#nodeId").val();
	var status="";
	var message=document.getElementsByName("message");
	for(var i=0;i<message.length;i++){
		if(message[i].checked){
			status="1";
		}
	}
	var area=$("textarea[tableIndex='yes']");
    	for(var i=0;i<area.length;i++){
    			area[i].value="\n  "+area[i].value+getUserDate($("#userName").val());
    	}
	var json="[";
	    json+="{'name':'message','value':'"+status+"'},{'name':'tableId','value':'"+$("#tableId").val()+"'},{'name':'exuctor','value':'"+actor+"'},{'name':'nodeId','value':'"+nodeId+"'},{'name':'userId','value':'"+$("#userId").val()+"'},{'name':'flowId','value':'"+$("#flowId").val()+"'}";
	   var param={"flowId":$("#flowId").val()};
	$.post("initFlowFormValueWrite.action",param,function(data){
		var proportyList=data.proportyList;
		for(var i=0;i<proportyList.length;i++){
			if(proportyList[i].type=='upload'){
			var table=$("#filetable").find("input[type=\"checkbox\"]");
				var fileId="";
				for(var j=0;j<table.length;j++){
			    fileId+="_"+table[j].value;
				}
				json+=",{'name':'"+proportyList[i].columnName+"','value':'"+fileId+"'}";
			}else{
				json+=",{'name':'"+proportyList[i].columnName+"','value':'"+$("#"+proportyList[i].columnName).val()+"'}";
			}
			}
		json+="]";
		json = json.replace(/\n/g,"\\n");
	     var values={"json":json};
			$.post("updateNextNode.action",values,function(data){
					alert("操作成功！");
					window.close();
					var currentPage=$("#currentPage").val();
					window.parent.opener.page(currentPage);
					
			});
		},"json");
}


function updateNextStep(nodeId,actor){
	var status="";
	var message=document.getElementsByName("message");
	for(var i=0;i<message.length;i++){
		if(message[i].checked){
			status="1";
		}
	}
	var area=$("textarea[tableIndex='yes']");
    	for(var i=0;i<area.length;i++){
   			area[i].value="\n  "+area[i].value+getUserDate($("#userName").val());
    	}
	var json="[";
	    json+="{'name':'message','value':'"+status+"'},{'name':'tableId','value':'"+$("#tableId").val()+"'},{'name':'exuctor','value':'"+actor+"'},{'name':'nodeId','value':'"+nodeId+"'},{'name':'instanceId','value':'"+$("#instanceId").val()+"'},{'name':'flowId','value':'"+$("#flowId").val()+"'}";
	   var param={"nodeIds":$("#currentNodeId").val()};
	$.post("initFormValueWrite.action",param,function(data){
		var proportyList=data.proportyList;
		for(var i=0;i<proportyList.length;i++){
			if(proportyList[i].type=='upload'){
			var table=$("#filetable").find("input[type=\"checkbox\"]");
				var fileId="";
				for(var j=0;j<table.length;j++){
			    fileId+="_"+table[j].value;
				}
				json+=",{'name':'"+proportyList[i].columnName+"','value':'"+fileId+"'}";
			}else{
				json+=",{'name':'"+proportyList[i].columnName+"','value':'"+$("#"+proportyList[i].columnName).val()+"'}";
			}
			}
		json+="]";
		json = json.replace(/\n/g,"\\n");
	     var values={"json":json};
			$.post("upFlowNextNode.action",values,function(data){
					alert("操作成功！");
					window.close();
					if($("#status").val()=='index'){
					window.opener.flowList();
					}else{
					var currentPage=$("#currentPage").val();
					window.opener.page(currentPage);
				}
			});
		},"json");
}

function getUserDate(name){
		var d = new Date();
		var vYear = d.getFullYear();
		var vMon = d.getMonth() + 1;
		var vDay = d.getDate();
		var h = d.getHours(); 
		var m = d.getMinutes(); 
		var se = d.getSeconds(); 
		var s=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)+" "+ (h<10 ? "0"+ h : h)+":"+ (m<10 ? "0" + m : m)+":"+ (se<10 ? "0" +se : se);
		var nbsp = "\n";
		for(var i = 0; i <= 16; i++){
			nbsp += "  ";
		}
		return nbsp+name+"  ("+s+")";
}

function getcandidateR(id) {
	var url = "getCandidate.action?nodeId=" + id;
	openWindow(url, 700, 400);
}

function getorguserR(id) {
	var url = "getOrgExecutor.action?nodeId=" + id;
	openWindow(url, 700, 400);
}

function flowLook(val) {
		var url = "flowLook.action?flowId="+val;
		openWindow(url, 680, 600);
	}
	
function downloadFile(id) {
	var fileId = $("#"+id).val();
	if (fileId != "" && fileId != "null") {
		var param = {"fileArray":fileId};
		$.post("getFileList.action", param, function (data) {
			var list = data.fileList;
			for (var i = 0; i < list.length; i++) {
				$("#filetable").prepend("<tr><td><input type=\"checkbox\" name=\"checkbox2\" id=\"" + list[i].id + "\" value=\"" + list[i].id + "\" />&nbsp;<a href=\"downLoadFile.action?fileId=" + list[i].id + "\">" + list[i].name + "</a>&nbsp;</tr>");
			}
		}, "json");
	}
}


function selectUser(val){
		var url="getFlowOrgUser.action?status="+val;
		openWindow(url,700,420);
	}

	
function backShow(val){
	if(val=='notShow'){
		document.getElementById("notShow").style.display = "none";
		document.getElementById("backList").style.display = "block";
	}else if(val=='backList'){
		document.getElementById("notShow").style.display = "block";
		document.getElementById("backList").style.display = "none";
	}else if(val=='notShow2'){
		document.getElementById("notShow2").style.display = "none";
		document.getElementById("backList2").style.display = "block";
	}else if(val=='backList2'){
		document.getElementById("notShow2").style.display = "block";
		document.getElementById("backList2").style.display = "none";
	}
}

function reject() {
	var nodeId=$("#backNodeId").val();
	var tableId=$("#tableId").val();
	var flowId=$("#flowId").val();
	var status="";
	var message=document.getElementsByName("message");
	for(var i=0;i<message.length;i++){
		if(message[i].checked){
			status="1";
		}
	}
	var param={"tableId":tableId,"flowId":flowId,"nodeIds":nodeId,"message":status};
	$.post("rejectWorkFlow.action", param, function (data) {
		if (data == "success") {
			alert("\u64cd\u4f5c\u6210\u529f");
			window.close();
			if($("#status").val()=='index'){
				window.opener.flowList();
			}else{
				var currentPage=$("#currentPage").val();
				window.opener.page(currentPage);
			}
			window.parent.opener.page(currentPage);
		} else {
			alert("\u64cd\u4f5c\u5931\u8d25");
		}
	});
}